﻿Imports System.Data.OleDb

Public Class ExportItemsDAO
    Public Function ExportItems_Delete_Forever(ByVal _date As Date) As Boolean
        Dim para(0) As OleDbParameter
        Dim p As New OleDbParameter("@ExportDate", _date)
        p.OleDbType = OleDbType.Date
        para(0) = p
        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ExportItems_Delete_Forever", para)
    End Function

    Public Function ExportItems_List() As DataSet
        'return two tables
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItems_List", Nothing)
    End Function

    Public Function ExportItems_Select(ByVal RecordID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        Dim p As New OleDbParameter("@RecordID", RecordID)
        p.OleDbType = OleDbType.Integer
        para(0) = p
        'return two tables
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItems_Select", para)
    End Function

    Public Function ExportItems_GetNextExportBill() As Integer
        Dim para(0) As OleDbParameter
        para(0) = New OleDbParameter("@ExportBill", OleDbType.Integer)
        para(0).Direction = ParameterDirection.Output
        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ExportItems_GetNextExportBill", para)
        Return para(0).Value
    End Function

    Public Function ExportItems_Insert(ByVal ExportBill As Integer, _
                                        ByVal TotalQuantity As Integer, _
                                        ByVal TotalSellPrice As Decimal, _
                                        ByVal VendorID As Integer, _
                                        ByVal Cashier As Integer, _
                                        ByVal Paied As Decimal, _
                                        ByVal debt As Decimal, _
                                        ByVal RateOfExchange As Integer, _
                                        ByVal ExportDate As Date, _
                                        ByVal VATTax As Double, _
                                        ByVal CreatedBy As String, _
                                        ByVal ExportItemID As Integer) As Integer
        Dim para(11) As OleDbParameter
        Dim p As New OleDbParameter()
        p = New OleDbParameter("@ExportBill", ExportBill)
        p.OleDbType = OleDbType.Integer
        'p.Value = ExportBill
        para(0) = p

        p = New OleDbParameter("@TotalQuantity", TotalQuantity)
        p.OleDbType = OleDbType.Integer
        'p.Value = TotalQuantity
        para(1) = p

        p = New OleDbParameter("@TotalSellPrice", TotalSellPrice)
        p.OleDbType = OleDbType.Currency
        'p.Value = TotalSellPrice
        para(2) = p

        p = New OleDbParameter("@VendorID", VendorID)
        p.OleDbType = OleDbType.Integer
        'p.Value = VendorID
        para(3) = p

        p = New OleDbParameter("@Cashier", Cashier)
        p.OleDbType = OleDbType.Integer
        'p.Value = Cashier
        para(4) = p

        p = New OleDbParameter("@Paied", Paied)
        p.OleDbType = OleDbType.Currency
        'p.Value = Paied
        para(5) = p

        p = New OleDbParameter("@debt", debt)
        p.OleDbType = OleDbType.Currency
        'p.Value = debt
        para(6) = p

        p = New OleDbParameter("@RateOfExchange", RateOfExchange)
        p.OleDbType = OleDbType.Numeric
        'p.Value = RateOfExchange
        para(7) = p

        p = New OleDbParameter("@ExportDate", ExportDate)
        p.OleDbType = OleDbType.Date
        'p.Value = ExportDate
        para(8) = p

        p = New OleDbParameter("@VATTax", VATTax)
        p.OleDbType = OleDbType.Integer
        'p.Value = VATTax
        para(9) = p

        p = New OleDbParameter("@CreatedBy", CreatedBy)
        p.OleDbType = OleDbType.VarWChar
        'p.Value = CreatedBy
        para(10) = p

        p = New OleDbParameter("@ExportItemID", OleDbType.Integer)
        p.Direction = ParameterDirection.Output
        'p.Value = ExportItemID
        para(11) = p
        objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ExportItems_Insert", para)
        Return para(11).Value

    End Function

    Public Function ExportItems_Update(ByVal ExportBill As Integer, _
                                        ByVal TotalQuantity As Integer, _
                                        ByVal TotalSellPrice As Decimal, _
                                        ByVal VendorID As Integer, _
                                        ByVal Cashier As Integer, _
                                        ByVal Paied As Decimal, _
                                        ByVal debt As Decimal, _
                                        ByVal RateOfExchange As Integer, _
                                        ByVal ExportDate As Date, _
                                        ByVal VATTax As Double, _
                                        ByVal ModifiedBy As String, _
                                        ByVal ExportItemID As Integer) As Boolean
        Try
            Dim para(11) As OleDbParameter
            Dim p As New OleDbParameter("@ExportBill", ExportBill)

            p.OleDbType = OleDbType.Integer
            'p.Value = ExportBill
            para(0) = p

            p = New OleDbParameter("@TotalQuantity", TotalQuantity)
            p.OleDbType = OleDbType.Integer
            'p.Value = TotalQuantity
            para(1) = p

            p = New OleDbParameter("@TotalSellPrice", TotalSellPrice)
            p.OleDbType = OleDbType.Currency
            'p.Value = TotalSellPrice
            para(2) = p

            p = New OleDbParameter("@VendorID", VendorID)
            p.OleDbType = OleDbType.Integer
            'p.Value = VendorID
            para(3) = p

            p = New OleDbParameter("@Cashier", Cashier)
            p.OleDbType = OleDbType.Integer
            'p.Value = Cashier
            para(4) = p

            p = New OleDbParameter("@Paied", Paied)
            p.OleDbType = OleDbType.Currency
            'p.Value = Paied
            para(5) = p

            p = New OleDbParameter("@debt", debt)
            p.OleDbType = OleDbType.Currency
            'p.Value = debt
            para(6) = p

            p = New OleDbParameter("@RateOfExchange", RateOfExchange)
            p.OleDbType = OleDbType.Numeric
            'p.Value = RateOfExchange
            para(7) = p

            p = New OleDbParameter("@ExportDate", ExportDate)
            p.OleDbType = OleDbType.Date
            'p.Value = ExportDate
            para(8) = p

            p = New OleDbParameter("@VATTax", VATTax)
            p.OleDbType = OleDbType.Integer
            'p.Value = VATTax
            para(9) = p

            p = New OleDbParameter("@ModifiedBy", ModifiedBy)
            p.OleDbType = OleDbType.VarWChar
            'p.Value = ModifiedBy
            para(10) = p

            p = New OleDbParameter("@ExportItemID", OleDbType.Integer)
            'p.Direction = ParameterDirection.Output
            'p.Value = ExportItemID
            para(11) = p
            Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ExportItems_Update", para)

        Catch ex As Exception
            Return False
        End Try

        Return True

    End Function

    Public Function ExportItemDetails_Delete(ByVal ExportItemDetailID As Integer) As Boolean
        Dim para(0) As OleDbParameter
        Dim p As New OleDbParameter("@ExportItemDetailID", ExportItemDetailID)
        p.OleDbType = OleDbType.Integer
        'p.Value = ExportItemDetailID
        para(0) = p

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ExportItemDetails_Delete", para)
    End Function

    Public Function ExportItems_Delete_Temp(ByVal ExportItemID As Integer, _
                                            ByVal ModifiedOn As Date, _
                                            ByVal ModifiedBy As String) As Boolean
        Dim para(2) As OleDbParameter
        Dim p As New OleDbParameter("@ExportItemID", ExportItemID)
        p.OleDbType = OleDbType.Integer
        para(0) = p

        p = New OleDbParameter("@ModifiedOn", ModifiedOn)
        p.OleDbType = OleDbType.Date
        para(1) = p

        p = New OleDbParameter("@ModifiedBy", ModifiedBy)
        p.OleDbType = OleDbType.VarWChar
        para(2) = p

        Return objConnectionDAO.ExecuteStoreprocedureNoneReturn("spTDT_ExportItems_Delete_Temp", para)

    End Function

    Public Function ExportItems_DSThu() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItems_DSThu", Nothing)
    End Function

    Public Function ExportItems_Info() As DataSet
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItems_Info", Nothing)
    End Function

    Public Function ExportItem_AccountsReceivable_TreeView() As DataSet
        'return two tables
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItem_AccountsReceivable_TreeView", Nothing)
    End Function

    Public Function ExportItems_AccountsReceivable_Select(ByVal ExportItemID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        Dim p As New OleDbParameter("@ExportItemID", ExportItemID)
        p.OleDbType = OleDbType.Integer
        'p.Value = ExportItemDetailID
        para(0) = p

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItems_AccountsReceivable_Select", para)
    End Function

    Public Function ExportItem_AccountsReceivable_Group(ByVal VendorID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        Dim p As New OleDbParameter("@VendorID", VendorID)
        p.OleDbType = OleDbType.Integer
        'p.Value = ExportItemDetailID
        para(0) = p

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItem_AccountsReceivable_Group", para)
    End Function

    Public Function ExportItem_AccountsReceivable_Delete(ByVal ExportItemID As Integer, _
                                                         ByVal Paied As Decimal, _
                                                         ByVal debt As Decimal, _
                                                         ByVal ModifiedOn As Date, _
                                                         ByVal ModifiedBy As String) As DataSet
        Dim para(4) As OleDbParameter
        para(0) = New OleDbParameter("@ExportItemID", ExportItemID)
        para(0).OleDbType = OleDbType.Integer

        para(1) = New OleDbParameter("@Paied", Paied)
        para(1).OleDbType = OleDbType.Currency

        para(2) = New OleDbParameter("@debt", debt)
        para(2).OleDbType = OleDbType.Currency

        para(3) = New OleDbParameter("@ModifiedOn", ModifiedOn)
        para(3).OleDbType = OleDbType.Date

        para(4) = New OleDbParameter("@ModifiedBy", ModifiedBy)
        para(4).OleDbType = OleDbType.VarWChar

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItem_AccountsReceivable_Delete", para)
    End Function

    Public Function ExportItems_TreeView() As DataSet
        'return two tables
        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItems_TreeView", Nothing)
    End Function

    Public Function ExportItems_Select_AccountsReceivable(ByVal RecordID As Integer) As DataSet
        Dim para(0) As OleDbParameter
        Dim p As New OleDbParameter("@RecordID", RecordID)
        p.OleDbType = OleDbType.Integer
        'p.Value = ExportItemDetailID
        para(0) = p

        Return objConnectionDAO.ExecuteStoreprocedure("spTDT_ExportItems_Select_AccountsReceivable", para)
    End Function

End Class
